import fs from 'fs';
import path from 'path';

// Check if the battery calculator file exists
const filePath = path.join(__dirname, '/iframe/calculators/battery-calculator.html');
console.log('Checking file existence at:', filePath);

if (fs.existsSync(filePath)) {
	console.log('✓ File exists!');
	const stats = fs.statSync(filePath);
	console.log('File size:', stats.size, 'bytes');

	// Try to read a small portion of the file to verify it's readable
	try {
		const data = fs.readFileSync(filePath, 'utf8', { encoding: 'utf8', start: 0, end: 100 });
		console.log('First 100 characters of file:', data);
	} catch (err) {
		console.error('Error reading file:', err.message);
	}
} else {
	console.log('✗ File does not exist!');

	// Check directory structure to debug
	const dirPath = path.join(__dirname, '/iframe/calculators');
	console.log('Checking directory existence:', dirPath);
	if (fs.existsSync(dirPath)) {
		console.log('Directory exists. Files in directory:');
		const files = fs.readdirSync(dirPath);
		files.forEach((file) => console.log('-', file));
	} else {
		console.log('Directory does not exist!');
	}
}
